import os
import sys
import logging
from pathlib import Path

def setup_logging():
    """设置日志配置"""
    log_dir = os.path.join(os.path.expanduser('~'), 'AppData', 'Local', '成帧数据应用软件', 'logs')
    os.makedirs(log_dir, exist_ok=True)
    
    log_file = os.path.join(log_dir, 'frame_analyzer.log')
    
    logging.basicConfig(
        level=logging.INFO,
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
        handlers=[
            logging.FileHandler(log_file, encoding='utf-8'),
            logging.StreamHandler()
        ]
    )

def setup_temp_dir():
    """设置临时文件目录"""
    temp_dir = os.path.join(os.path.expanduser('~'), 'AppData', 'Local', '成帧数据应用软件', 'temp')
    os.makedirs(temp_dir, exist_ok=True)
    return temp_dir

# 运行时初始化
setup_logging()
os.environ['TEMP_DIR'] = setup_temp_dir() 